package regex;
/**
 * String类与正则相关的方法
 *    public String replaceAll(String regex, String replacement):将字符串中匹配正则表达式的字符串替换成指定的字符串
 */
public class RegexDemo08 {
    public static void main(String[] args) {
        //method01();

        //要求将连续的数字替换成* 123=>*
        String str = "abc123def56gkki";
        String replacestr = str.replaceAll("\\d+", "*");
        System.out.println(replacestr);
    }

    private static void method01() {
        //要求把每个数字都替换成* 123=>***
        String str = "abc123def56gkki";
        String replacestr = str.replaceAll("\\d", "*");
        System.out.println(replacestr);
    }
}
